package cn.fuck;

import java.util.Arrays;
interface A {
    int x = 9;
}
class Phone implements Comparable<Phone> {
    private double price;

    public Phone(double price) {
        this.price = price;
    }

    @Override
    public int compareTo(Phone o) {
        return Double.compare(this.price, o.price);
    }

    @Override
    public String toString() {
        return this.price + "";
    }
}
public class TestComparable {


    public static void main(String[] args) {
        Phone[] phones = new Phone[3];

        Phone iPhone10 = new Phone(9999);
        Phone iPhone5 = new Phone(999);
        Phone iPhone9 = new Phone(5000);

        phones[0] = iPhone10;
        phones[1] = iPhone5;
        phones[2] = iPhone9;
        Arrays.sort(phones);
        System.out.println(Arrays.toString(phones));
    }
}
